package com.egg.ylt.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.egg.ylt.R;
import com.egg.ylt.Utils.GlideRoundTransform;
import com.egg.ylt.Utils.GlideUtils;
import com.egg.ylt.Utils.StringUtil;
import com.egg.ylt.pojo.ActionVideoEntity;
import com.egg.ylt.pojo.NatatoriumByidEntity;
import com.yonyou.framework.library.adapter.rv.CommonAdapter;
import com.yonyou.framework.library.adapter.rv.ViewHolder;
import com.yonyou.framework.library.common.utils.DisplayUtil;

/**
 * Created by qiuzhenhuan on 2019/2/26.
 */

public class ADA_AlbumList extends CommonAdapter<NatatoriumByidEntity.BannerListBean> {

    private Context mContext;


    public ADA_AlbumList(Context context) {
        super(context);
        this.mContext = context;
    }

    @Override
    protected int itemLayoutId() {
        return R.layout.item_album_list;
    }

    @Override
    protected void convert(ViewHolder holder, NatatoriumByidEntity.BannerListBean listBean, int position) {
        holder.setVisible(R.id.tv_title, listBean.getImageType() == NatatoriumByidEntity.IMAGE_TYPE_BANNER);
        Glide.with(mContext).load(listBean.getImageUrl())
                .placeholder(R.mipmap.ic_growth_default)
                .centerCrop()
                .transform(new GlideRoundTransform(mContext, 3))
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into((ImageView) holder.getView(R.id.iv_image));


        FrameLayout flRoot = holder.getView(R.id.fl_root);
        ViewGroup.LayoutParams params = flRoot.getLayoutParams();
        int widthHeight = (DisplayUtil.getDisplayMetrics(mContext).widthPixels - DisplayUtil.dip2px(mContext, 10)) / 2;
        params.width = widthHeight;
        params.height = widthHeight;
        flRoot.setLayoutParams(params);
    }
}
